#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int a[100];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    int sum = 5, max = 5;
    for (int i = 0; i < n; i++)
    {
        sum = sum - a[i];
        if (sum > max)
        {
            max = sum;
        }
    }
    printf("%d", max);
    return 0;
}